﻿@{
    ViewBag.Title = "List3";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script type="text/javascript">
    var deleteLinkObj;
    // delete Link
    $('.delete').click(function () {
        deleteLinkObj = $(this);  //for future use
        $('#delete-dialog').dialog('open');
        return false; // prevents the default behaviour
    });
    $('#delete-dialog').dialog({
        autoOpen: false, width: 400, resizable: false, modal: true, //Dialog options
        buttons: {
            "Continue": function () {
                $.post(deleteLinkObj[0].href, function (data) {  //Post to action
                    if (data == 'True') {
                        deleteLinkObj.closest("tr").hide('fast'); //Hide Row
                        //(optional) Display Confirmation
                    }
                    else {
                        //(optional) Display Error
                    }
                });
                $(this).dialog("close");
            },
            "Cancel": function () {
                $(this).dialog("close");
            }
        }
    });
</script>

<h2>List3</h2>

@model IEnumerable <JChatSerVices.CountryService.countryproperties>
           
@using (Html.BeginForm("List4", "Country", new { _id = "_id" }, FormMethod.Get, new { enctype = "multipart/form-data", }))
{
    <p>ID @Html.TextBox("_id")
    <input type ="submit" value="Search" /></p>
}

<p>@Html.ActionLink("Create", "AddCountry")</p>
           
           <table cellspacing="0"  class="listTable" id="postList">
				
					<thead>
						<tr>
							<th>CountryID</th>
							<th>NameCountry</th>
					        <th></th>
						</tr>
					</thead>
					
					<tbody>
                      @foreach (var item in Model)
                      { 
						<tr>
							<td valign="middle" align="center">@item.CountryID</td>
                            <td valign="middle" align="center">@item.NameCountry</td>
							<td align="center">
                                @Html.ActionLink("Delete", "Delete", new { id = item.CountryID}, new { @class ="delete" }) |
                                @Html.ActionLink("Update", "Update", new { _id = item.CountryID })
                            </td>
						</tr>
                      }
					</tbody>
					<!-- /Tbody -->
				</table>

<div id="delete-dialog" title="Confirmation"><p>Are you sure you want to delete this?</p></div>
